﻿<div appBsModal #createOrEditModal="bs-modal" class="modal fade" tabindex="-1" role="dialog"
     aria-labelledby="createOrEditModal" aria-hidden="true" [config]="{backdrop: 'static', keyboard: !saving}">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">
                    <span
                        *ngIf="dynamicPropertyValue&& !dynamicPropertyValue.id">{{"AddNewDynamicPropertyValue" | localize}}</span>
                    <span
                        *ngIf="dynamicPropertyValue&&dynamicPropertyValue.id">{{"EditDynamicPropertyValue" | localize}}</span>
                </h4>
                <button type="button" class="close" (click)="close()" [attr.aria-label]="l('Close')"
                        [disabled]="saving">
                    <i aria-hidden="true" class="ki ki-close"></i>
                </button>
            </div>
            <div class="modal-body" *ngIf="dynamicPropertyValue">
                <div class="row justify-content-end px-5">
                    <button class="btn btn-outline-brand btn-sm btn-icon btn-icon-md"
                            (click)="getDynamicProperties()">
                        <i class="flaticon2-refresh"></i>
                    </button>
                    <button *ngIf="'Pages.Administration.DynamicPropertyValue.Create' | permission"
                            class="btn btn-outline-brand btn-sm btn-icon btn-icon-md"
                            (click)="createDynamicPropertyValue()">
                        <i class="flaticon2-plus"></i>
                    </button>
                </div>
                <div class="row" *ngIf="createOrEditValueEnabled">
                    <div class="form-group col">
                        <label for="Name">{{"Value" | localize}} *</label>

                        <div class="input-group">
                            <input class="form-control col" type="text" name="Name"
                                   [(ngModel)]="dynamicPropertyValue.value"
                                   required>
                            <div class="input-group-append">
                                <button class="btn btn-primary" type="button" (click)="save()">Save</button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row align-items-center">

                    <!--<Primeng-TurboTable-Start>-->
                    <div class="col primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                        <p-table #dataTable (onLazyLoad)="getDynamicProperties()"
                                 [value]="primengTableHelper.records"
                                 rows="{{primengTableHelper.defaultRecordsCountPerPage}}" [paginator]="false"
                                 [lazy]="true"
                                 [responsive]="primengTableHelper.isResponsive">
                            <ng-template pTemplate="header">
                                <tr>
                                    <th> {{'Values' | localize}} </th>
                                    <th style="width: 100px;"></th>
                                    <th style="width: 100px;"></th>
                                </tr>
                            </ng-template>
                            <ng-template pTemplate="body" let-record="$implicit">
                                <tr>
                                    <td>
                                        {{record.value}}
                                    </td>
                                    <td>
                                        <button class="btn btn-primary"
                                                *ngIf="'Pages.Administration.DynamicPropertyValue.Edit' | permission"
                                                (click)="editDynamicPropertyValue(record.id)">{{'Edit' | localize}}</button>
                                    </td>
                                    <td>
                                        <button class="btn btn-danger"
                                                *ngIf="'Pages.Administration.DynamicPropertyValue.Delete' | permission"
                                                (click)="deleteDynamicPropertyValue(record.id)">{{'Delete' | localize}}</button>
                                    </td>
                                </tr>
                            </ng-template>
                        </p-table>
                        <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
                            {{'NoData' | localize}}
                        </div>
                    </div>
                    <!--<Primeng-TurboTable-End>-->
                </div>
            </div>
            <div class="modal-footer">
                <button [disabled]="saving" type="button" class="btn btn-light-primary font-weight-bold"
                        (click)="close()">{{"Close" | localize}}</button>
            </div>
        </div>
    </div>
</div>
